/**
 * Copyright (c) 2012-3-25, lysong01@gmail.com. All rights reserved.
 * 题目大意（回忆版）：该题是要翻转数据。首先输入一个5 * 5的数组，然后输入一行，这一行有四个数，前两个代表操作类型，后两个数x y代表需操作数据为以x y为左上角的那几个数据。  

操作类型有四种：  
1 2 表示：90度，顺时针，翻转4个数  
1 3 表示：90度，顺时针，翻转9个数  
2 2 表示：90度，逆时针，翻转4个数  
2 3 表示：90度，逆时针，翻转9个数  
 
Sample:  
 
Input:  
1 2 3 4 5  
6 7 8 9 10  
11 12 13 14 15  
16 17 18 19 20  
21 22 23 24 25  
1 3 1 1  
 
Output:  
11 6 1 4 5  
12 7 2 9 10  
13 8 3 14 15  
16 17 18 19 20  
21 22 23 24 25  
 */
package bupt.jike;

import java.util.Scanner;

/**
 * @author  liyasong
 * @version %I%, %G%
 * @since   liyasong1.0
 */
public class Pro2010_3 {

	/**
	 * @param args
	 * void
	 */
	private static int[][] tranpose(int [][] array, int x, int y, int wide) {
		int[][] temp = new int[wide][wide];
		for (int i = x-1; i < x-1+wide; i++) {
			for (int j = y-1; j < y-1+wide; j++) {
				temp[i+1-x][j+1-y] = array[j][i];
			}
		}
		return temp;
	}
	//顺时针替换子数组
	private static void repalce(int[][] array, int [][] subarray, int x, int y) {
		int wide = subarray.length;
		for (int i = y-1; i < y-1+wide; i++) {
			for (int j = x-1; j < x-1+wide; j++) {
				array[i][j] = subarray[i+1-y][wide-1-(j+1-x)];
			}
		}
	}
	//逆时针替换子数组
	private static void anrepalce(int[][] array, int [][] subarray, int x, int y) {
		int wide = subarray.length;
		for (int i = y-1; i < y-1+wide; i++) {
			for (int j = x-1; j < x-1+wide; j++) {
				array[i][j] = subarray[wide-1-(i+1-y)][j+1-x];
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int [][] array = new int[5][5];
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 5; j++) {
				array[i][j] = sca.nextInt();
			}
		}
		int opera1 = sca.nextInt();
		int opera2 = sca.nextInt();
		int x = sca.nextInt();
		int y = sca.nextInt();
		int [][] temp = null;
		switch (opera2) {
		case 2:
			temp = tranpose(array, x, y, 2);
			break;
		case 3:
			temp = tranpose(array, x, y, 3);
			break;
		default:
			break;
		}
		switch (opera1) {
		case 1:
			repalce(array, temp, x, y);
			break;
		case 2:
			anrepalce(array, temp, x, y);
		default:
			break;
		}
		
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 5; j++) {
				System.out.print(array[i][j]+" ");
			}
			System.out.println();
		}
	}

}
